package com.data.center.dictionary;

import com.data.center.exception.exception.BizException;
import com.data.center.exception.info.CommonEnum;

/**
 * @author Li_Jx
 * @description: 行政区划区域字典
 * @date 2023/9/8 20:20
 */
public enum AdminDivisionRegion {
    WEST("01", "西部"),
    HK_MO_TW("02","港澳台"),
    EAST("03","东部"),
    CENTRAL("04","中部"),
    NORTHEAST("05","东北"),

    DEFAULT("00","无")
    ;

    private final String key;
    private final String value;

    AdminDivisionRegion(String key, String value) {
        this.key = key;
        this.value = value;
    }

    public String getKey() {
        return key;
    }

    public String getValue() {
        return value;
    }

    public static AdminDivisionRegion getObjectByKey(String key){
        for (AdminDivisionRegion adminDivisionRegion : AdminDivisionRegion.values()) {
            if (adminDivisionRegion.getKey().equals(key)){
                return adminDivisionRegion;
            }
        }
        throw new BizException(CommonEnum.CAN_NOT_FIND_IN_DICTIONARY);
    }
    public static AdminDivisionRegion getObjectByValue(String value){
        for (AdminDivisionRegion adminDivisionRegion : AdminDivisionRegion.values()) {
            if (adminDivisionRegion.getValue().equals(value)){
                return adminDivisionRegion;
            }
        }
        throw new BizException(CommonEnum.CAN_NOT_FIND_IN_DICTIONARY);
    }
}
